package netty.demo.nio.fileChannel;

import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;

/**
 * @author Zed
 * @description 删除操作 很危险 无法在回收站找回
 * @date 2022/10/22 22:20
 */
public class testFilesWalkFileTreeDelete {

    public static void main(String[] args) throws IOException {
        Files.walkFileTree(Paths.get("D:\\MSOCache"), new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                Files.delete(file);
                return super.visitFile(file, attrs);
            }

            @Override
            public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                Files.delete(dir);
                return super.postVisitDirectory(dir, exc);
            }
        });
    }
}
